package com.zhuss.exception;

import java.util.Arrays;
import java.util.List;

import com.zhuss.common.DefaultDataResponse;
import com.zhuss.common.Response;

public class AabException extends Exception {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -5744630198800785728L;

	private Integer code;
	
	private String msg;
	
	private Response data = new DefaultDataResponse();
	
	public AabException (String msg, Integer code) {
		this.code = code;
		this.msg = msg;
		this.data.setData(msg);
	}
	
	/*public AabException (ExceptionCode exceptionCode, Object data) {
		this.code = exceptionCode.code;
		this.msg = exceptionCode.msg;
		this.data.setData(data);
	}*/
	
	public AabException (ExceptionCode exceptionCode) {
		this.code = exceptionCode.code;
		this.msg = exceptionCode.msg;
		this.data.setData(exceptionCode.msg);
	}
	
	public AabException (ExceptionCode exceptionCode, String... patterns) {
		List<String> patternList = Arrays.asList(patterns);
		this.code = exceptionCode.code;
		this.msg = String.format(exceptionCode.msg, patternList);
		this.data.setData(exceptionCode.msg);
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Response getData() {
		return data;
	}

	public void setData(Response data) {
		this.data = data;
	}

}
